import { ref, computed } from 'vue'
import type { Ref } from 'vue'
import { defineStore } from 'pinia'
interface IHospitalInfo {
  kinds: string
  grade: string
  name: string
  image: string
  desc: string
  text: string
}
interface IDoctorInfo {
  kinds: string
  hospital: string
  position: string
  name: string
  image: string
  desc: string
}
interface IReservation {
  doctorname: string
  kinds: string
  hospital: string
  visitor: string
  gender: string
  age: string
  medicalInsurance?: string
  image:string
  position:string
}
export const useCounterStore = defineStore('counter', () => {
  const hospital: Ref<number> = ref(0)
  const city: Ref<string> = ref('')
  const department: Ref<string> = ref('')
  const body: Ref<string> = ref('')
  const hospitalInfo: Ref<number> = ref(0)
  const doctorInfo: Ref<IDoctorInfo> = ref({ kinds: '', hospital: '', name: "", image: '', desc: '', position: '' })
  // const doctorInfo: Ref<number> = ref(0)
  function gethospital(val: any) {
    hospital.value = val
  }
  function getcity(val: any) {
    city.value = val
  }
  function getdepartment(val: any) {
    department.value = val
  }
  function getbody(val: any) {
    body.value = val
  }
  function gethospitalInfo(val: any) {
    hospitalInfo.value = val
  }
  function getdoctorInfo(val: any) {
    doctorInfo.value = val
  }
  const sayId: Ref<number> = ref(0)
  const username: Ref<string> = ref('123456')
  const userId: Ref<string> = ref('')
  const reservationId: Ref<number> = ref(0)


  // 获取Id
  function getSayId(val: number) {
    sayId.value = val
  }

  // 获取userId
  function getUserId(val: string) {
    userId.value = val
  }

  // 修改resertionId
  function setReservationId(val: number) {
    reservationId.value = val
  }

  // 获取预约数据
  
  const reservationInfo: Ref<IReservation> = ref({
    doctorname: '',
    kinds: '',
    hospital: '',
    visitor: '',
    gender: '',
    age: '',
    medicalInsurance: '',
    image:'',
    position:''
  })
  function getReservationInfo(val: IReservation) {
    reservationInfo.value = val
  }

  return { hospital, gethospital, city, getcity, gethospitalInfo, hospitalInfo, department, getdepartment, body, getbody, doctorInfo, getdoctorInfo, sayId, getSayId, username, userId, getUserId, reservationId, setReservationId, reservationInfo, getReservationInfo }
}, { persist: { storage: window.localStorage } })
